﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Linq;
using System.Xml.Linq;

namespace RFW.Silverlight.Weather
{
	public class Pressure
	{
		public string Description { get; set; }
		public double MB { get; set; }
		public double IN { get; set; }

		public override string ToString()
		{
			return this.Description;
		}

		internal void Process(XDocument doc)
		{
			var data = from o in doc.Descendants("current_observation")
					   select new Pressure
					   {
						   Description = o.Element("pressure_string").Value,
						   MB = Convert.ToDouble(o.Element("pressure_mb").Value),
						   IN = Convert.ToDouble(o.Element("pressure_in").Value),
					   };

			foreach (Pressure o in data)
			{
				this.Description = o.Description;
				this.MB = o.MB;
				this.IN = o.IN;
			}
		}
	}
}
